package com.yunyouyi.CacheModel;

import java.util.LinkedHashMap;
import java.util.Map;

public class LRUCache<K,V> extends SimpleCache<K,V> {
    private final int capacity;

    public LRUCache(int capacity) {
        super(new LinkedHashMap<>(capacity, 0.75f, true) {
            @Override
            protected boolean removeEldestEntry(Map.Entry<K, CacheEntry<V>> eldest) {
                return size() > capacity;
            }
        });
        this.capacity = capacity;
    }
}
